package com.a.basis.testexpand;
//          数组的扩容2
public class TestExpand2 {
    public static void main(String[] args) {
        int[] oldArray=new int[]{1,2,3,4,5};
        //创建比原数组更大的新数组
        int[] newArray=new int[oldArray.length*2];

        //原始数组，原数组起始，新数组，新数组起始，长度
        System.arraycopy(oldArray,0,newArray,0,oldArray.length);

        for (int i = 0; i < newArray.length; i++) {
            System.out.print(newArray[i]+"\t");
        }
    }
}
